package com.fyakm.javaprojectanalysis.demo;

import com.fyakm.javaprojectanalysis.common.base.F_Package;
import com.fyakm.javaprojectanalysis.common.util.JavaFileParserUtil;
import com.fyakm.javaprojectanalysis.common.util.XmindUtil;
import com.fyakm.javaprojectanalysis.common.util.ZipUtil;
import org.junit.Test;

import java.io.File;
import java.io.IOException;

/**
 * 工具类单元测试
 */
public class UtilTestDemo {

    /**
     * 测试解压Zip文件
     */
    @Test
    public void testZipUtil(){

        String zipFilePath = "C:\\Users\\fyakm\\Desktop\\temp\\cas-overlay-template-7.0.zip";
        String destDirector = "C:\\Users\\fyakm\\Desktop\\temp\\ddd";
        try {
            ZipUtil.unzip(zipFilePath,destDirector);
        } catch (IOException e) {

            throw new RuntimeException(e);
        }

    }


    /**
     * 测试JavaParser解析Java项目
     */
    @Test
    public void testJavaParserUtil_parser(){
        String filePath = "D:\\work\\project\\pink";
        // 解析Java项目成F_Package格式
        F_Package aPackage = JavaFileParserUtil.getPackage(new File(filePath));
        // 格式化输出
        F_Package.formatPrint(0,aPackage);
    }

    /**
     * 测试生成Xmind
     */
    @Test
    public void testXmindUtil(){
        String filePath = "D:\\work\\project\\pink";
        // 解析Java项目成F_Package格式
        F_Package aPackage = JavaFileParserUtil.getPackage(new File(filePath));
        // 生成Xmind文件
        XmindUtil.generatorXmind(aPackage,"C:\\Users\\fyakm\\Desktop\\temp\\pink.xmind",false);
    }

    /**
     * 测试输出所有导包
     */
    @Test
    public void testExportImportList(){
        JavaFileParserUtil.exportImportPackageToTxt(new File("D:\\work\\project\\pink"),"C:\\Users\\fyakm\\Desktop\\temp\\importList.txt");
    }


}
